import instacne from "../request";
import type { Ref } from "vue";

// 查询订单约束list约束
interface seachyuesu {
  createTime: string;
  id: number;
  note: string;
  orderSn: string;
  orderType: number;
  sourceType: number;
  status: number;
  totalAmount: number;
}

// 查询订单响应数据约束
interface seacglist {
  list: seachyuesu[];
  pageNum: number;
  pageSize: number;
  total: number;
  totalPage: number;
}

// 查询订单参数约束
interface IorderParams {
  createTime?: string;
  orderSn?: string;
  orderType?: number | string;
  pageNum?: number;
  pageSize?: number;
  receiverKeyword?: string;
  sourceType?: number | string;
  status?: number | string;
}

// 查询订单
const orderlist = (data?: IorderParams): Promise<seacglist> => {
  return instacne.get("/order/list", {
    params: data,
  });
};

//修改指定订单设置
const orderSetUpdate = (data: {
  // ? 可选可不选
  commentOvertime?: number;
  confirmOvertime?: number;
  finishOvertime?: number;
  flashOrderOvertime?: number;
  // id必选
  id: number;
  normalOrderOvertime?: number;
}) => {
  // 注意：data 这里已经是一个对象
  return instacne.post(`/orderSetting/update/${data.id}`, data);
};

//获取指定订单设置约束
interface Orderconstraint {
  commentOvertime: number;
  confirmOvertime: number;
  finishOvertime: number;
  flashOrderOvertime: number;
  id: number;
  normalOrderOvertime: number;
}
//获取指定订单设置
const orderSetting = (data: number): Promise<Orderconstraint> => {
  return instacne.get(`/orderSetting/${data}`);
};

// 获取订单详情 退货申请处理
const orderDetail = (data: any): Promise<any> => {
  return instacne.get(`/order/${data.id}`, data);
};

export { orderlist, orderSetting, orderSetUpdate, orderDetail };
export type { Orderconstraint, seachyuesu };
